/******************************************************************************
 * * sms_delete.c - implementation of sms delete functions
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#include "sms_include.h"

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete function
    // create Messages_Delete_Msgs chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pDelete    = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDelete = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pDelete, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 5);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 5);

    g_MsgGlobalCtrl.pChart     = pDelete;
    g_MsgGlobalCtrl.CurOpenBox = DELETE_MESSAGES;

    pDelete->TitleBar.TxtId      = PHONE_TEXT_ID_DEL_SMS;
    pDelete->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pDelete->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pDelete->List.ListButtonCnt  = 5;
    pDelete->List.Index          = 0;
    pDelete->List.ButtonList     = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_ALL_READ;
    ButtonList[0].ReleaseFun  = Sms_Delete_All_Read;
    ButtonList[0].Valid       = true;
    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_INBOX;
    ButtonList[1].ReleaseFun  = Sms_Delete_Inbox;
    ButtonList[1].Valid       = true;
    ButtonList[2].ButtonIndex = 2;
    ButtonList[2].TxtId       = PHONE_TEXT_ID_DRAFTS;
    ButtonList[2].ReleaseFun  = Sms_Delete_Drafts;
    ButtonList[2].Valid       = true;
    ButtonList[3].ButtonIndex = 3;
    ButtonList[3].TxtId       = PHONE_TEXT_ID_SENT_ITEMS;
    ButtonList[3].ReleaseFun  = Sms_Delete_Sent_Items;
    ButtonList[3].Valid       = true;
    ButtonList[4].ButtonIndex = 4;
    ButtonList[4].TxtId       = PHONE_TEXT_ID_SCREENED_SMS_ABBR;
    ButtonList[4].ReleaseFun  = Sms_Delete_Screened_Sms;
    ButtonList[4].Valid       = true;

    pDelete->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDelete->BtnBar.ButtonR.Valid = true;

    pDelete->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pDelete->BtnBar.ButtonM.Valid = true;

    pDelete->KeyFunc = Sms_Delete_Msg_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Delete_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_MSGS, &FuncList, (void *)pDelete);
} /* Sms_Delete */

/**
 * Common Process UI destroy event
 * param (in) pDesc:  VOID *
 * return  void
 */
VOID Sms_Delete_Destory(VOID *pDesc)
{
    UI_Normal_List_Only_Desc_t *pInput = pDesc;

    Hal_Mem_Free(pInput->List.ButtonList);
    pInput->List.ButtonList = NULL;
    Sms_Common_All_Global_Destory(pDesc);
}

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Msg_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }
    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_All_Read(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete msgs all read call back function
    // create Messages_Delete_Read_All_Confirm chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteAllRead = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDeleteAllRead = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteAllRead, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart     = pDeleteAllRead;
    g_MsgGlobalCtrl.CurOpenBox = MSG_DEL_ALL_READ;

    pDeleteAllRead->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteAllRead->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DEL_READ_SMS_ALL_FOLDER;
    pDeleteAllRead->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteAllRead->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteAllRead->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteAllRead->ButtonBar.ButtonR.Valid = true;

    pDeleteAllRead->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteAllRead->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteAllRead->ButtonBar.ButtonM.Valid      = true;

    pDeleteAllRead->KeyFunc = Sms_Delete_All_Read_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_READ_ALL_CONFIRM, &FuncList, (void *)pDeleteAllRead);
} /* Sms_Delete_All_Read */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_All_Read_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_All_Read_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_All_Read_OK(lv_obj_t *pBtn)
{
    // create Messages_Delete_Status chart
    // inform modem adapter to delete all read messages
    NV_UI_Sms_Drafts_t *data = NULL;
    Nav_Func_List_t    FuncList;
    UI_Status_Desc_t   *pDeleteSts = NULL;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    g_MsgGlobalCtrl.CurOpenBox = MSG_DEL_ALL_READ;

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    pDeleteSts->KeyFunc = Sms_Delete_All_Read_OK_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    // set the new drafts to NVM
    data = (NV_UI_Sms_Drafts_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_Drafts_t));
    Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_Drafts_t));
    UI_NV_Write_Req(NV_SECTION_UI_SMS_DRAFTS, 0, sizeof(NV_UI_Sms_Drafts_t), (UINT8 *)data);
    Hal_Mem_Free(data);
    data = NULL;
    MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_ALL);

    return(LV_RES_OK);
} /* Sms_Delete_All_Read_OK */
/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_All_Read_OK_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }
    return(Result);   // temp
}
/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_All_Read_Done(VOID* id)
{
    // refresh Messages_Delete_Status chart
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteDone = NULL;
    CB_FUNC          callback     = Sms_Delete_All_Read_Done_Timeout;

    Sms_Timer_Stop_And_Destroy(id);

    pDeleteDone = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteDone, 0, sizeof(UI_Status_Desc_t));

    pDeleteDone->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteDone->ContLabel.TxtId      = PHONE_TEXT_ID_DELETED;
    pDeleteDone->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteDone->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteDone->ContImg.Img = SYMBOL_CHECKED;

    pDeleteDone->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pDeleteDone->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_MESSAGES_DELETED_STATUS, ACT_ID_MESSAGES_DELETED_DONE, &FuncList, (void *)pDeleteDone);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_DONE);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_All_Read_Done_Timeout(VOID* id)
{
    // back to Messages_Delete_Msgs chart
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES_DELETE_MSGS, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Inbox(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete msgs inbox call back function
    // create Messages_Delete_Opt. chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pDelInbox  = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDelInbox = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pDelInbox, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 3);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 3);

    g_MsgGlobalCtrl.pChart = pDelInbox;

    pDelInbox->TitleBar.TxtId      = PHONE_TEXT_ID_INBOX;
    pDelInbox->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pDelInbox->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pDelInbox->List.ListButtonCnt  = 3;
    pDelInbox->List.Index          = 0;
    pDelInbox->List.ButtonList     = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_ONE_BY_ONE;
    ButtonList[0].ReleaseFun  = Sms_Delete_Inbox_Options_Onebyone;
    ButtonList[0].Valid       = true;
    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_ALL_READ;
    ButtonList[1].ReleaseFun  = Sms_Delete_Inbox_Options_Allread;
    ButtonList[1].Valid       = true;
    ButtonList[2].ButtonIndex = 2;
    ButtonList[2].TxtId       = PHONE_TEXT_ID_DELETE_ALL;
    ButtonList[2].ReleaseFun  = Sms_Delete_Inbox_Options_All;
    ButtonList[2].Valid       = true;

    pDelInbox->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDelInbox->BtnBar.ButtonR.Valid = true;

    pDelInbox->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pDelInbox->BtnBar.ButtonM.Valid = true;

    pDelInbox->KeyFunc = Sms_Delete_Msg_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_OPT, &FuncList, (void *)pDelInbox);
} /* Sms_Delete_Inbox */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Inbox_Options_Onebyone(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete msgs inbox options one by one call back function
    // create Messages_Opening chart or Messages_Delete_Folder_Status
    // 2 seconds timer start
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pOpening = NULL;
    CB_FUNC          callback  = Sms_Del_Inbox_Timeout;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pOpening = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pOpening, 0, sizeof(UI_Status_Desc_t));

    g_MsgGlobalCtrl.CurOpenBox = MSG_DEL_INBOX_ONEBYONE;

    pOpening->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pOpening->ContLabel.TxtId      = PHONE_TEXT_ID_OPENING;
    pOpening->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pOpening->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pOpening->ContImg.Img      = IMG_PROGRESS_BAR;
    pOpening->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pOpening->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    pOpening->KeyFunc = Sms_Delete_Inbox_Options_Onebyone_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_OPENING, &FuncList, (void *)pOpening);

    if (NULL != g_MsgGlobalCtrl.pInboxMsgContentInfo)
    {    // inbox has been read
        // 2s timer start
        Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_OPENING);
    }
    else
    {
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_RECEIVED);
    }
} /* Sms_Delete_Inbox_Options_Onebyone */
/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Inbox_Options_Onebyone_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }
    return(Result);   // temp
}
/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Inbox_Timeout(VOID* id)
{
    // create Messages_Inbox chart
    UINT32* Id = (UINT32 *)id;
    Sms_Del_Inbox_List(*Id);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Inbox_List(UINT32 id)
{
    // Inbox messages list function
    // create Messages_Inbox chart
    UINT32                     i   = 0;
    UINT32                     Cnt = 0;
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pInbox     = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;
    Msg_Content_Info_t         *pTemp      = NULL;

    pInbox = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pInbox, 0, sizeof(UI_Normal_List_Only_Desc_t));

    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);

    while (NULL != pTemp)
    {
        Cnt++;
        pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
    }

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * Cnt);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * Cnt);

    g_MsgGlobalCtrl.pChart = pInbox;

    pInbox->TitleBar.TxtId      = PHONE_TEXT_ID_INBOX;
    pInbox->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pInbox->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pInbox->List.ListButtonCnt = Cnt;
    pInbox->List.Index         = 0;
    pInbox->List.ButtonList    = ButtonList;

    for (i = 0; i < Cnt; i++)
    {
        if (i)
        {
            pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
        }
        else
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);
        }
        ButtonList[i].ButtonIndex = 0xFF;
        ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        ButtonList[i].BtnTxt      = pTemp->pContact;
        if (MMI_MODEM_UNREAD == pTemp->SmsType)
        {
            ButtonList[i].SymbolId1 = SYMBOL_UNREAD_SMS;
        }
        else
        {
            ButtonList[i].SymbolId1 = SYMBOL_READ_SMS;
        }
        if (MMI_MODEM_SIM_1 == pTemp->SimId)
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM1;
        }
        else
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM2;
        }
        ButtonList[i].ReleaseFun = NULL;
        ButtonList[i].Valid      = true;
    }
    pInbox->BtnBar.ButtonL.TxtId = PHONE_TEXT_ID_BACK;
    pInbox->BtnBar.ButtonL.Valid = true;

    pInbox->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pInbox->BtnBar.ButtonM.Valid = true;

    pInbox->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_DONE;
    pInbox->BtnBar.ButtonR.Valid = true;

    pInbox->KeyFunc = Sms_Del_Inbox_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Inbox_On_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Inbox_On_Create;          // temp

    Nav_Forward(id, ACT_ID_MESSAGES_INBOX, &FuncList, (void *)pInbox);
} /* Sms_Del_Inbox_List */

/**
 * entry of message APP
 * param (in) void
 * return  void
 */
UINT8 Sms_Del_Inbox_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8              Result  = 0;
    Msg_Content_Info_t *pTemp  = NULL;
    Msg_Content_Info_t *pTemp1 = NULL;
    lv_obj_t           *pBtn   = NULL;

    pBtn = lv_list_get_btn_selected(obj);

    pTemp1 = pBtn->user_data.user_data;
    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTLEFT == key_val)
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);

            while (NULL != pTemp)
            {
                if (MMI_MODEM_UNSENT == pTemp->SmsType)
                {
                    pTemp->SmsType = MMI_MODEM_READ;
                }
                pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
            }
            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_OPT, NULL, NULL);
            Result = 1;
        }
        else if (KEY_SOFTRIGHT == key_val)
        {        // done
            Sms_Delete_Inbox_Onebyone_Done(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {        // select
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);

            while (NULL != pTemp)
            {
                if (pTemp1->MsgIndex == pTemp->MsgIndex)
                {
                    if (MMI_MODEM_UNSENT == pTemp->SmsType)
                    {                    // make to unmarked
                        lv_img_set_src(lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, NULL))), SYMBOL_READ_SMS);
                        pTemp->SmsType = MMI_MODEM_READ;
                    }
                    else
                    {                    // make to marked
                        lv_img_set_src(lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, NULL))), SYMBOL_CHECKED);
                        pTemp->SmsType = MMI_MODEM_UNSENT;
                    }
                    break;
                }
                pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
            }
            Result = 1;
        }
    }

    return(Result);    // temp
} /* Sms_Del_Inbox_Handle */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Inbox_Folder_Sts(VOID)
{
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pInboxEmpty = NULL;
    CB_FUNC          callback     = Sms_Del_Inbox_Empty_Timeout;

    pInboxEmpty = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pInboxEmpty, 0, sizeof(UI_Status_Desc_t));

    pInboxEmpty->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pInboxEmpty->ContLabel.TxtId      = PHONE_TEXT_ID_INBOX_EMPTY;
    pInboxEmpty->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pInboxEmpty->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pInboxEmpty->ContImg.Img      = LV_SYMBOL_WARNING;
    pInboxEmpty->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pInboxEmpty->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_FOLDER_STATUS, &FuncList, (void *)pInboxEmpty);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETE_FOLDER_STATUS);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Inbox_Empty_Timeout(VOID* id)
{
    // back to Messages_Delete_Msgs chart
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES_DELETE_MSGS, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Inbox_Onebyone_Done(lv_obj_t *pBtn)
{
    // create Messages_Delete_Mark_Confirm chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteOnebyone = NULL;

    pDeleteOnebyone = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteOnebyone, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDeleteOnebyone;

    pDeleteOnebyone->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteOnebyone->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DELETE_MARKED_SMS_Q;
    pDeleteOnebyone->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteOnebyone->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteOnebyone->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteOnebyone->ButtonBar.ButtonR.Valid = true;

    pDeleteOnebyone->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteOnebyone->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteOnebyone->ButtonBar.ButtonM.Valid      = true;

    pDeleteOnebyone->KeyFunc = Sms_Delete_Inbox_Onebyone_Done_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_MARK_CONFIRM, &FuncList, (void *)pDeleteOnebyone);

    return(LV_RES_OK);
}

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Inbox_Onebyone_Done_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Inbox_Delete_Mark_Cnf_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Inbox_Delete_Mark_Cnf_OK(lv_obj_t *pBtn)
{
    // create Messages_Delete_Status chart
    // send the delete messages indexes to modem adapter(optional)
    // if delete finished,2 seconds timer start
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;
    CB_FUNC          callback    = Sms_Delete_All_Read_Done;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    Sms_Common_Delete_Sms(MSG_DEL_INBOX_ONEBYONE, (VOID **)&g_MsgGlobalCtrl.pInboxMsgContentInfo);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Inbox_Options_Allread(lv_obj_t *pBtn,lv_event_t event)
{
    // create Messages_Delete_Msgs chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteAllRead = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDeleteAllRead = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteAllRead, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart     = pDeleteAllRead;
    g_MsgGlobalCtrl.CurOpenBox = MSG_DEL_INBOX_ALLREAD;

    pDeleteAllRead->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteAllRead->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DEL_ALL_READ_SMS_FOLDER;
    pDeleteAllRead->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteAllRead->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteAllRead->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteAllRead->ButtonBar.ButtonR.Valid = true;

    pDeleteAllRead->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteAllRead->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteAllRead->ButtonBar.ButtonM.Valid      = true;

    pDeleteAllRead->KeyFunc = Sms_Delete_Inbox_Options_Allread_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_ALL_READ_CONFIRM, &FuncList, (void *)pDeleteAllRead);
} /* Sms_Delete_Inbox_Options_Allread */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Inbox_Options_Allread_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Inbox_Options_Allread_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Inbox_Options_Allread_OK(lv_obj_t *pBtn)
{
    if (NULL != g_MsgGlobalCtrl.pInboxMsgContentInfo)
    {    // inbox has been read
        Sms_Delete_Inbox_Options_Allread_OK_Sub();
    }
    else
    {
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_RECEIVED);
    }

    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Inbox_Options_Allread_OK_Sub(VOID)
{
    // create Messages_Delete_Status chart
    // inform modem adapter to delete all read messages
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;
    CB_FUNC          callback    = Sms_Delete_All_Read_Done;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    Sms_Common_Delete_Sms(MSG_DEL_INBOX_ALLREAD, (VOID **)&g_MsgGlobalCtrl.pInboxMsgContentInfo);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Inbox_Options_All(lv_obj_t *pBtn,lv_event_t event)
{
    // create Messages_Delete_Msgs chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteAll = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDeleteAll = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteAll, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart     = pDeleteAll;
    g_MsgGlobalCtrl.CurOpenBox = MSG_DEL_INBOX_ALL;

    pDeleteAll->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteAll->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DEL_ALL_SMS_FOLDER;
    pDeleteAll->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteAll->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteAll->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteAll->ButtonBar.ButtonR.Valid = true;

    pDeleteAll->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteAll->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteAll->ButtonBar.ButtonM.Valid      = true;

    pDeleteAll->KeyFunc = Sms_Delete_Inbox_Options_All_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_ALL_CONFIRM, &FuncList, (void *)pDeleteAll);
} /* Sms_Delete_Inbox_Options_All */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Inbox_Options_All_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Inbox_Options_All_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Inbox_Options_All_OK(lv_obj_t *pBtn)
{
    if (NULL != g_MsgGlobalCtrl.pInboxMsgContentInfo)
    {    // inbox has been read
        Sms_Delete_Inbox_Options_All_OK_Sub();
    }
    else
    {
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_RECEIVED);
    }

    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Inbox_Options_All_OK_Sub(VOID)
{
    // create Messages_Delete_Status chart
    // inform modem adapter to delete all messages
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;
    CB_FUNC          callback    = Sms_Delete_All_Read_Done;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    Sms_Common_Delete_Sms(MSG_DEL_INBOX_ALL, (VOID **)&g_MsgGlobalCtrl.pInboxMsgContentInfo);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Drafts(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete msgs drafts call back function
    // create Messages_Delete_Opt. chart
    UINT32                     i      = 0;
    INT8                       str    = '\0';
    NV_UI_Sms_Drafts_t         *data  = NULL;
    Msg_Content_Info_t         *pTemp = NULL;
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pDelDrafts = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDelDrafts = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pDelDrafts, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 2);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 2);

    data = (NV_UI_Sms_Drafts_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_Drafts_t));
    Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_Drafts_t));
    UI_NV_Read_Req(NV_SECTION_UI_SMS_DRAFTS, 0, sizeof(NV_UI_Sms_Drafts_t), (UINT8 *)data);
    Sms_Common_Free_Msg_Content_Info(&g_MsgGlobalCtrl.pDraftMsgContentInfo);
    g_MsgGlobalCtrl.pDraftMsgContentInfo = (lv_ll_t *)Hal_Mem_Alloc(sizeof(lv_ll_t));
    Hal_Mem_Set(g_MsgGlobalCtrl.pDraftMsgContentInfo, 0, sizeof(lv_ll_t));
    _lv_ll_init(g_MsgGlobalCtrl.pDraftMsgContentInfo, sizeof(Msg_Contact_List_Info_t));

    for (i = 0; false != strcmp((INT8 *)data->Drafts[i].DraftContent, &str); i++)
    {
        if (10 == i)
        {
            break;
        }
        if (i)
        {
            pTemp = _lv_ll_ins_tail(g_MsgGlobalCtrl.pDraftMsgContentInfo);
            Hal_Mem_Set(pTemp, 0, sizeof(Msg_Contact_List_Info_t));
        }
        else
        {
            pTemp = _lv_ll_ins_head(g_MsgGlobalCtrl.pDraftMsgContentInfo);
            Hal_Mem_Set(pTemp, 0, sizeof(Msg_Contact_List_Info_t));
        }
        pTemp->MsgIndex = i;
    }
    if (0 == i)
    {
        Sms_Common_Free_Msg_Content_Info(&g_MsgGlobalCtrl.pDraftMsgContentInfo);
    }
    Hal_Mem_Free(data);
    data                   = NULL;
    g_MsgGlobalCtrl.pChart = pDelDrafts;

    pDelDrafts->TitleBar.TxtId      = PHONE_TEXT_ID_DRAFTS;
    pDelDrafts->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pDelDrafts->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pDelDrafts->List.ListButtonCnt  = 2;
    pDelDrafts->List.Index          = 0;
    pDelDrafts->List.ButtonList     = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_ONE_BY_ONE;
    ButtonList[0].ReleaseFun  = Sms_Delete_Drafts_Options_Onebyone;
    ButtonList[0].Valid       = true;
    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_ALL_READ;
    ButtonList[1].ReleaseFun  = Sms_Delete_Drafts_Options_Allread;
    ButtonList[1].Valid       = true;

    pDelDrafts->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDelDrafts->BtnBar.ButtonR.Valid = true;

    pDelDrafts->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pDelDrafts->BtnBar.ButtonM.Valid = true;

    pDelDrafts->KeyFunc = Sms_Delete_Msg_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_OPT, &FuncList, (void *)pDelDrafts);
} /* Sms_Delete_Drafts */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Drafts_Options_Onebyone(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete msgs drafts options one by one call back function
    // create Messages_Opening chart or Messages_Delete_Folder_Status
    // 2 seconds timer start
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pOpening = NULL;
    CB_FUNC          callback  = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pOpening = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pOpening, 0, sizeof(UI_Status_Desc_t));

    pOpening->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pOpening->ContLabel.TxtId      = PHONE_TEXT_ID_OPENING;
    pOpening->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pOpening->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pOpening->ContImg.Img      = IMG_PROGRESS_BAR;
    pOpening->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pOpening->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_OPENING, &FuncList, (void *)pOpening);

    if (NULL != g_MsgGlobalCtrl.pDraftMsgContentInfo)
    {    // drafts has been read
        // 2s timer start
        callback = Sms_Del_Drafts_Timeout;
        // Sms_Del_Drafts_Timeout
    }
    else
    {
        callback = Sms_Delete_Drafts_Folder_Sts_Timeout;
        // Sms_Delete_Drafts_Folder_Sts_Timeout
    }
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_OPENING);
} /* Sms_Delete_Drafts_Options_Onebyone */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Drafts_Timeout(VOID* id)
{
    // create Messages_Inbox chart
    UINT32* Id = (UINT32 *)id;
    Sms_Del_Drafts_List(*Id);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Drafts_List(UINT32 id)
{
    // Sent Drafts messages list function
    // create Messages_Drafts
    // or Messages_Drafts_empty chart
    UINT32                     i      = 0;
    UINT32                     Cnt    = 0;
    Msg_Content_Info_t         *pTemp = NULL;
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pDrafts    = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;
    NV_UI_Sms_Draft_Content_t  *data       = NULL;

    pDrafts = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pDrafts, 0, sizeof(UI_Normal_List_Only_Desc_t));

    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pDraftMsgContentInfo);

    while (NULL != pTemp)
    {
        Cnt++;
        pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pDraftMsgContentInfo, pTemp);
    }

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * Cnt);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * Cnt);

    g_MsgGlobalCtrl.pChart = pDrafts;

    pDrafts->TitleBar.TxtId      = PHONE_TEXT_ID_DRAFTS;
    pDrafts->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pDrafts->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pDrafts->List.ListButtonCnt = Cnt;
    pDrafts->List.Index         = 0;
    pDrafts->List.ButtonList    = ButtonList;

    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pDraftMsgContentInfo);

    while (NULL != pTemp)
    {
        ButtonList[i].ButtonIndex = i;
        ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        data                      = (NV_UI_Sms_Draft_Content_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_Draft_Content_t));
        Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_Drafts_t));
        UI_NV_Read_Req(NV_SECTION_UI_SMS_DRAFTS, NV_SMS_MAX_INPUT_NUM * pTemp->MsgIndex + 1, sizeof(NV_UI_Sms_Draft_Content_t), (UINT8 *)data);
        ButtonList[i].BtnTxt = Hal_Mem_Alloc(MSG_DRAFT_DISPLAY_LEN);
        Hal_Mem_Set(ButtonList[i].BtnTxt, 0, MSG_DRAFT_DISPLAY_LEN);
        Hal_Mem_Copy(ButtonList[i].BtnTxt, data->DraftContent, MSG_DRAFT_DISPLAY_LEN);
        pTemp->SmsType           = MMI_MODEM_READ;
        ButtonList[i].SymbolId1  = SYMBOL_READ_SMS;
        ButtonList[i].ReleaseFun = NULL;
        ButtonList[i].Valid      = true;
        pTemp                    = _lv_ll_get_next(g_MsgGlobalCtrl.pDraftMsgContentInfo, pTemp);
        i++;
    }
    Hal_Mem_Free(data);
    data                          = NULL;
    pDrafts->BtnBar.ButtonL.TxtId = PHONE_TEXT_ID_BACK;
    pDrafts->BtnBar.ButtonL.Valid = true;

    pDrafts->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pDrafts->BtnBar.ButtonM.Valid = true;

    pDrafts->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_DONE;
    pDrafts->BtnBar.ButtonR.Valid = true;

    pDrafts->KeyFunc = Sms_Del_Drafts_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Drafts_List_On_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Drafts_List_On_Create;    // temp

    Nav_Forward(id, ACT_ID_MESSAGES_DRAFTS, &FuncList, (void *)pDrafts);
} /* Sms_Del_Drafts_List */

/**
 * entry of message APP
 * param (in) void
 * return  void
 */
UINT8 Sms_Del_Drafts_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8              Result  = 0;
    Msg_Content_Info_t *pTemp  = NULL;
    Msg_Content_Info_t *pTemp1 = NULL;
    lv_obj_t           *pBtn   = NULL;

    pBtn = lv_list_get_btn_selected(obj);

    pTemp1 = pBtn->user_data.user_data;
    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTLEFT == key_val)
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pDraftMsgContentInfo);

            while (NULL != pTemp)
            {
                if (MMI_MODEM_UNREAD == pTemp->SmsType)
                {
                    pTemp->SmsType = MMI_MODEM_READ;
                }
                pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pDraftMsgContentInfo, pTemp);
            }
            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_OPT, NULL, NULL);
            Result = 1;
        }
        else if (KEY_SOFTRIGHT == key_val)
        {        // done
            Sms_Delete_Drafts_Onebyone_Done();
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {        // select
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pDraftMsgContentInfo);

            while (NULL != pTemp)
            {
                if (pTemp1->MsgIndex == pTemp->MsgIndex)
                {
                    if (MMI_MODEM_UNREAD == pTemp->SmsType)
                    {                    // make to unmarked
                        lv_img_set_src(lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, NULL)), SYMBOL_READ_SMS);
                        pTemp->SmsType = MMI_MODEM_READ;
                    }
                    else
                    {                    // make to marked
                        lv_img_set_src(lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, NULL)), SYMBOL_CHECKED);
                        pTemp->SmsType = MMI_MODEM_UNREAD;
                    }
                    break;
                }
                pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pDraftMsgContentInfo, pTemp);
            }
            Result = 1;
        }
    }

    return(Result);    // temp
} /* Sms_Del_Drafts_Handle */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Drafts_Folder_Sts_Timeout(VOID* id)
{
    UINT32* Id = (UINT32 *)id;
    Sms_Delete_Drafts_Folder_Sts(*Id);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Drafts_Folder_Sts(UINT32 id)
{
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pEmpty  = NULL;
    CB_FUNC          callback = Sms_Del_Drafts_Empty_Timeout;

    pEmpty = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pEmpty, 0, sizeof(UI_Status_Desc_t));

    pEmpty->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pEmpty->ContLabel.TxtId      = PHONE_TEXT_ID_DRAFTS_EMPTY;
    pEmpty->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pEmpty->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pEmpty->ContImg.Img      = LV_SYMBOL_WARNING;
    pEmpty->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pEmpty->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(id, ACT_ID_MESSAGES_DELETE_FOLDER_STATUS, &FuncList, (void *)pEmpty);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETE_FOLDER_STATUS);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Drafts_Empty_Timeout(VOID* id)
{
    // back to Messages_Delete_Msgs chart
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES_DELETE_MSGS, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Drafts_Onebyone_Done(VOID)
{
    // create Messages_Delete_Mark_Confirm chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteOnebyone = NULL;

    pDeleteOnebyone = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteOnebyone, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDeleteOnebyone;

    pDeleteOnebyone->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteOnebyone->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DELETE_MARKED_SMS_Q;
    pDeleteOnebyone->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteOnebyone->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteOnebyone->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteOnebyone->ButtonBar.ButtonR.Valid = true;

    pDeleteOnebyone->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteOnebyone->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteOnebyone->ButtonBar.ButtonM.Valid      = true;

    pDeleteOnebyone->KeyFunc = Sms_Delete_Drafts_Onebyone_Done_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_MARK_CONFIRM, &FuncList, (void *)pDeleteOnebyone);
}

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Drafts_Onebyone_Done_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Drafts_Delete_Mark_Cnf_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Drafts_Delete_Mark_Cnf_OK(lv_obj_t *pBtn)
{
    // create Messages_Delete_Status chart
    // delete messages to NVM(optional)
    // if delete finished,2 seconds timer start
    UINT32             i      = 0;
    NV_UI_Sms_Drafts_t *data  = NULL;
    NV_UI_Sms_Drafts_t *data1 = NULL;
    Msg_Content_Info_t *pTemp = NULL;
    Nav_Func_List_t    FuncList;
    UI_Status_Desc_t   *pDeleteSts = NULL;
    CB_FUNC            callback    = Sms_Delete_Drafts_Delete_Mark_Cnf_OK_Timeout;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    // set the new drafts to NVM
    data = (NV_UI_Sms_Drafts_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_Drafts_t));
    Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_Drafts_t));
    data1 = (NV_UI_Sms_Drafts_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_Drafts_t));
    Hal_Mem_Set(data1, 0, sizeof(NV_UI_Sms_Drafts_t));
    UI_NV_Read_Req(NV_SECTION_UI_SMS_DRAFTS, 0, sizeof(NV_UI_Sms_Drafts_t), (UINT8 *)data);
    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pDraftMsgContentInfo);

    while (NULL != pTemp)
    {
        if (MMI_MODEM_UNREAD == pTemp->SmsType)
        {
            Hal_Mem_Copy(data1->Drafts[data1->Count].DraftContent, data->Drafts[pTemp->MsgIndex].DraftContent, NV_SMS_MAX_INPUT_NUM);
            data1->Count++;
        }
        pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pDraftMsgContentInfo, pTemp);
    }
    UI_NV_Write_Req(NV_SECTION_UI_SMS_DRAFTS, 0, sizeof(NV_UI_Sms_Drafts_t), (UINT8 *)data1);
    Sms_Common_Free_Msg_Content_Info(&g_MsgGlobalCtrl.pDraftMsgContentInfo);
    g_MsgGlobalCtrl.pDraftMsgContentInfo = (lv_ll_t *)Hal_Mem_Alloc(sizeof(lv_ll_t));
    Hal_Mem_Set(g_MsgGlobalCtrl.pDraftMsgContentInfo, 0, sizeof(lv_ll_t));
    _lv_ll_init(g_MsgGlobalCtrl.pDraftMsgContentInfo, sizeof(Msg_Content_Info_t));

    for (i = 0; i < data1->Count; i++)
    {
        if (i)
        {
            pTemp = _lv_ll_ins_tail(g_MsgGlobalCtrl.pDraftMsgContentInfo);
            Hal_Mem_Set(pTemp, 0, sizeof(Msg_Content_Info_t));
        }
        else
        {
            pTemp = _lv_ll_ins_head(g_MsgGlobalCtrl.pDraftMsgContentInfo);
            Hal_Mem_Set(pTemp, 0, sizeof(Msg_Content_Info_t));
        }
        pTemp->MsgIndex = i;
    }
    Hal_Mem_Free(data);
    data = NULL;
    Hal_Mem_Free(data1);
    data1 = NULL;
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);

    return(LV_RES_OK);
} /* Sms_Delete_Drafts_Delete_Mark_Cnf_OK */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Drafts_Delete_Mark_Cnf_OK_Timeout(VOID* id)
{
    UINT32 Id = MSG_INVAILD_TIMER_ID;
    Sms_Delete_All_Read_Done(&Id);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  VOID
 */
VOID Sms_Delete_Drafts_Options_Allread(lv_obj_t *pBtn,lv_event_t event)
{
    // create Messages_Delete_Msgs chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteAllRead = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDeleteAllRead = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteAllRead, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDeleteAllRead;

    pDeleteAllRead->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteAllRead->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DEL_ALL_READ_SMS_FOLDER;
    pDeleteAllRead->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteAllRead->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteAllRead->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteAllRead->ButtonBar.ButtonR.Valid = true;

    pDeleteAllRead->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteAllRead->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteAllRead->ButtonBar.ButtonM.Valid      = true;

    pDeleteAllRead->KeyFunc = Sms_Delete_Drafts_Options_Allread_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_ALL_READ_CONFIRM, &FuncList, (void *)pDeleteAllRead);
}

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Drafts_Options_Allread_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Drafts_Options_Allread_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Drafts_Options_Allread_OK(lv_obj_t *pBtn)
{
    CB_FUNC callback = Sms_Delete_Drafts_Folder_Sts_Timeout;

    if (NULL != g_MsgGlobalCtrl.pDraftMsgContentInfo)
    {    // Drafts has been read
        Sms_Delete_Drafts_Options_Allread_OK_Sub();
    }
    else
    {
        // 2s timer start
        Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETE_ALL_READ_CONFIRM);
        // Sms_Delete_Drafts_Folder_Sts_Timeout
    }

    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Drafts_Options_Allread_OK_Sub(VOID)
{
    // create Messages_Delete_Status chart
    // inform NVM to delete all read messages
    NV_UI_Sms_Drafts_t *data = NULL;
    Nav_Func_List_t    FuncList;
    UI_Status_Desc_t   *pDeleteSts = NULL;
    CB_FUNC            callback    = Sms_Delete_Drafts_Delete_Mark_Cnf_OK_Timeout;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    // set the new drafts to NVM
    data = (NV_UI_Sms_Drafts_t *)Hal_Mem_Alloc(sizeof(NV_UI_Sms_Drafts_t));
    Hal_Mem_Set(data, 0, sizeof(NV_UI_Sms_Drafts_t));
    UI_NV_Write_Req(NV_SECTION_UI_SMS_DRAFTS, 0, sizeof(NV_UI_Sms_Drafts_t), (UINT8 *)data);
    Hal_Mem_Free(data);
    data = NULL;
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);
    // Sms_Delete_Drafts_Delete_Mark_Cnf_OK_Timeout
} /* Sms_Delete_Drafts_Options_Allread_OK_Sub */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Sent_Items(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete msgs sent items call back function
    // create Messages_Delete_Opt. chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pDelSentItems = NULL;
    UI_Button_Desc_t           *ButtonList    = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDelSentItems = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pDelSentItems, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 2);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 2);

    g_MsgGlobalCtrl.pChart = pDelSentItems;

    pDelSentItems->TitleBar.TxtId      = PHONE_TEXT_ID_SENT_ITEMS;
    pDelSentItems->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pDelSentItems->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pDelSentItems->List.ListButtonCnt  = 2;
    pDelSentItems->List.Index          = 0;
    pDelSentItems->List.ButtonList     = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_ONE_BY_ONE;
    ButtonList[0].ReleaseFun  = Sms_Delete_Sent_Items_Options_Onebyone;
    ButtonList[0].Valid       = true;
    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_ALL_READ;
    ButtonList[1].ReleaseFun  = Sms_Delete_Sent_Items_Options_Allread;
    ButtonList[1].Valid       = true;

    pDelSentItems->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDelSentItems->BtnBar.ButtonR.Valid = true;

    pDelSentItems->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pDelSentItems->BtnBar.ButtonM.Valid = true;

    pDelSentItems->KeyFunc = Sms_Delete_Msg_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_OPT, &FuncList, (void *)pDelSentItems);
} /* Sms_Delete_Sent_Items */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Sent_Items_Options_Onebyone(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete msgs sent items options one by one call back function
    // create Messages_Opening chart or Messages_Delete_Folder_Status
    // 2 seconds timer start
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pOpening = NULL;
    CB_FUNC          callback  = Sms_Del_Sent_Items_Timeout;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pOpening = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pOpening, 0, sizeof(UI_Status_Desc_t));

    g_MsgGlobalCtrl.CurOpenBox = MSG_DEL_SENT_ITEMS_ONEBYONE;

    pOpening->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pOpening->ContLabel.TxtId      = PHONE_TEXT_ID_OPENING;
    pOpening->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pOpening->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pOpening->ContImg.Img      = IMG_PROGRESS_BAR;
    pOpening->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pOpening->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_OPENING, &FuncList, (void *)pOpening);

    if (NULL != g_MsgGlobalCtrl.pSentboxMsgContentInfo)
    {    // sent items has been read
        // 2s timer start
        Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_OPENING);
    }
    else
    {
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_SENT);
    }
} /* Sms_Delete_Sent_Items_Options_Onebyone */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Sent_Items_Timeout(VOID* id)
{
    UINT32* Id = (UINT32 *)id;
    Sms_Del_Sent_Items_List(*Id);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Sent_Items_List(UINT32 id)
{
    // sent items messages list function
    UINT32                     i   = 0;
    UINT32                     Cnt = 0;
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pSentItems = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;
    Msg_Content_Info_t         *pTemp      = NULL;

    pSentItems = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pSentItems, 0, sizeof(UI_Normal_List_Only_Desc_t));

    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pSentboxMsgContentInfo);

    while (NULL != pTemp)
    {
        Cnt++;
        pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pSentboxMsgContentInfo, pTemp);
    }

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * Cnt);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * Cnt);

    g_MsgGlobalCtrl.pChart = pSentItems;

    pSentItems->TitleBar.TxtId      = PHONE_TEXT_ID_SENT_ITEMS;
    pSentItems->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pSentItems->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pSentItems->List.ListButtonCnt = Cnt;
    pSentItems->List.Index         = 0;
    pSentItems->List.ButtonList    = ButtonList;

    for (i = 0; i < Cnt; i++)
    {
        if (i)
        {
            pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pSentboxMsgContentInfo, pTemp);
        }
        else
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pSentboxMsgContentInfo);
        }
        ButtonList[i].ButtonIndex = 0xFF;
        ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        ButtonList[i].BtnTxt      = pTemp->pContact;
        if (MMI_MODEM_UNSENT == pTemp->SmsType)
        {
            ButtonList[i].SymbolId1 = SYMBOL_UNREAD_SMS;
        }
        else
        {
            ButtonList[i].SymbolId1 = SYMBOL_READ_SMS;
        }
        if (MMI_MODEM_SIM_1 == pTemp->SimId)
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM1;
        }
        else
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM2;
        }
        ButtonList[i].ReleaseFun = NULL;
        ButtonList[i].Valid      = true;
    }
    pSentItems->BtnBar.ButtonL.TxtId = PHONE_TEXT_ID_BACK;
    pSentItems->BtnBar.ButtonL.Valid = true;

    pSentItems->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pSentItems->BtnBar.ButtonM.Valid = true;

    pSentItems->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_DONE;
    pSentItems->BtnBar.ButtonR.Valid = true;

    pSentItems->KeyFunc = Sms_Del_Sent_Items_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Sent_Items_On_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Sent_Items_On_Create;     // temp

    Nav_Forward(id, ACT_ID_MESSAGES_SENT_ITEMS, &FuncList, (void *)pSentItems);
} /* Sms_Del_Sent_Items_List */

/**
 * entry of message APP
 * param (in) void
 * return  void
 */
UINT8 Sms_Del_Sent_Items_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8              Result  = 0;
    Msg_Content_Info_t *pTemp  = NULL;
    Msg_Content_Info_t *pTemp1 = NULL;
    lv_obj_t           *pBtn   = NULL;

    pBtn = lv_list_get_btn_selected(obj);

    pTemp1 = pBtn->user_data.user_data;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTLEFT == key_val)
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pSentboxMsgContentInfo);

            while (NULL != pTemp)
            {
                if (MMI_MODEM_READ == pTemp->SmsType)
                {
                    pTemp->SmsType = MMI_MODEM_SENT;
                }
                pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pSentboxMsgContentInfo, pTemp);
            }
            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_OPT, NULL, NULL);
            Result = 1;
        }
        else if (KEY_SOFTRIGHT == key_val)
        {        // done
            Sms_Delete_Sent_Items_Onebyone_Done(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {        // select
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pSentboxMsgContentInfo);

            while (NULL != pTemp)
            {
                if (pTemp1->MsgIndex == pTemp->MsgIndex)
                {
                    if (MMI_MODEM_READ == pTemp->SmsType)
                    {                    // make to unmarked
                        lv_img_set_src(lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, NULL))), SYMBOL_READ_SMS);
                        pTemp->SmsType = MMI_MODEM_SENT;
                    }
                    else
                    {                    // make to marked
                        lv_img_set_src(lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, NULL))), SYMBOL_CHECKED);
                        pTemp->SmsType = MMI_MODEM_READ;
                    }
                    break;
                }
                pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pSentboxMsgContentInfo, pTemp);
            }
            Result = 1;
        }
    }
// make the mark message to unread
    return(Result);    // temp
} /* Sms_Del_Sent_Items_Handle */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Sent_Items_Folder_Sts(VOID)
{
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pEmpty  = NULL;
    CB_FUNC          callback = Sms_Sent_Items_Empty_Timeout;

    pEmpty = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pEmpty, 0, sizeof(UI_Status_Desc_t));

    pEmpty->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pEmpty->ContLabel.TxtId      = PHONE_TEXT_ID_SENT_ITEMS_EMPTY;
    pEmpty->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pEmpty->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pEmpty->ContImg.Img      = LV_SYMBOL_WARNING;
    pEmpty->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pEmpty->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_FOLDER_STATUS, &FuncList, (void *)pEmpty);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETE_FOLDER_STATUS);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Sent_Items_Empty_Timeout(UINT32 id)
{
    // back to Messages_Delete_Msgs chart
    Nav_Forward(id, ACT_ID_MESSAGES_DELETE_MSGS, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Sent_Items_Onebyone_Done(lv_obj_t *pBtn)
{
    // create Messages_Delete_Mark_Confirm chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteOnebyone = NULL;

    pDeleteOnebyone = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteOnebyone, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDeleteOnebyone;

    pDeleteOnebyone->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteOnebyone->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DELETE_MARKED_SMS_Q;
    pDeleteOnebyone->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteOnebyone->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteOnebyone->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteOnebyone->ButtonBar.ButtonR.Valid = true;

    pDeleteOnebyone->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteOnebyone->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteOnebyone->ButtonBar.ButtonM.Valid      = true;

    pDeleteOnebyone->KeyFunc = Sms_Delete_Sent_Items_Onebyone_Done_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_MARK_CONFIRM, &FuncList, (void *)pDeleteOnebyone);

    return(LV_RES_OK);
}

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Sent_Items_Onebyone_Done_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Sent_Items_Delete_Mark_Cnf_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Sent_Items_Delete_Mark_Cnf_OK(lv_obj_t *pBtn)
{
    // create Messages_Delete_Status chart
    // send the delete messages indexes to modem adapter(optional)
    // if delete finished,2 seconds timer start
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;
    CB_FUNC          callback    = Sms_Delete_All_Read_Done;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    Sms_Common_Delete_Sms(MSG_DEL_SENT_ITEMS_ONEBYONE, (VOID **)&g_MsgGlobalCtrl.pSentboxMsgContentInfo);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Sent_Items_Options_Allread(lv_obj_t *pBtn,lv_event_t event)
{
    // create Messages_Delete_Msgs chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteAllRead = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDeleteAllRead = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteAllRead, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDeleteAllRead;

    g_MsgGlobalCtrl.CurOpenBox = MSG_DEL_SENT_ITEMS_ALLREAD;

    pDeleteAllRead->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteAllRead->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DEL_ALL_READ_SMS_FOLDER;
    pDeleteAllRead->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteAllRead->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteAllRead->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteAllRead->ButtonBar.ButtonR.Valid = true;

    pDeleteAllRead->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteAllRead->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteAllRead->ButtonBar.ButtonM.Valid      = true;

    pDeleteAllRead->KeyFunc = Sms_Delete_Sent_Items_Options_Allread_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_ALL_READ_CONFIRM, &FuncList, (void *)pDeleteAllRead);
} /* Sms_Delete_Sent_Items_Options_Allread */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Sent_Items_Options_Allread_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Sent_Items_Options_Allread_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Sent_Items_Options_Allread_OK(lv_obj_t *pBtn)
{
    if (NULL != g_MsgGlobalCtrl.pSentboxMsgContentInfo)
    {    // sent items has been read
        Sms_Delete_Sent_Items_Options_Allread_OK_Sub();
    }
    else
    {
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_SENT);
    }

    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Sent_Items_Options_Allread_OK_Sub(VOID)
{
    // create Messages_Delete_Status chart
    // inform modem adapter to delete all read messages
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;
    CB_FUNC          callback    = Sms_Delete_All_Read_Done;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    Sms_Common_Delete_Sms(MSG_DEL_SENT_ITEMS_ALLREAD, (VOID **)&g_MsgGlobalCtrl.pSentboxMsgContentInfo);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Screened_Sms(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete msgs of screened sms call back function
    // create Messages_Delete_Opt. chart
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pDelScrnSms = NULL;
    UI_Button_Desc_t           *ButtonList  = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDelScrnSms = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pDelScrnSms, 0, sizeof(UI_Normal_List_Only_Desc_t));

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * 3);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * 3);

    g_MsgGlobalCtrl.pChart = pDelScrnSms;

    pDelScrnSms->TitleBar.TxtId      = PHONE_TEXT_ID_SCREENED_SMS;
    pDelScrnSms->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pDelScrnSms->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;
    pDelScrnSms->List.ListButtonCnt  = 3;
    pDelScrnSms->List.Index          = 0;
    pDelScrnSms->List.ButtonList     = ButtonList;

    ButtonList[0].ButtonIndex = 0;
    ButtonList[0].TxtId       = PHONE_TEXT_ID_ONE_BY_ONE;
    ButtonList[0].ReleaseFun  = Sms_Delete_Scrn_Options_Onebyone;
    ButtonList[0].Valid       = true;
    ButtonList[1].ButtonIndex = 1;
    ButtonList[1].TxtId       = PHONE_TEXT_ID_ALL_READ;
    ButtonList[1].ReleaseFun  = Sms_Delete_Scrn_Options_Allread;
    ButtonList[1].Valid       = true;
    ButtonList[2].ButtonIndex = 2;
    ButtonList[2].TxtId       = PHONE_TEXT_ID_DELETE_ALL;
    ButtonList[2].ReleaseFun  = Sms_Delete_Scrn_Options_All;
    ButtonList[2].Valid       = true;

    pDelScrnSms->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDelScrnSms->BtnBar.ButtonR.Valid = true;

    pDelScrnSms->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pDelScrnSms->BtnBar.ButtonM.Valid = true;

    pDelScrnSms->KeyFunc = Sms_Delete_Msg_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Common_Restore;           // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_OPT, &FuncList, (void *)pDelScrnSms);
} /* Sms_Delete_Screened_Sms */

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Scrn_Options_Onebyone(lv_obj_t *pBtn,lv_event_t event)
{
    // sms delete msgs inbox options one by one call back function
    // create Messages_Opening chart or Messages_Delete_Folder_Status
    // 2 seconds timer start
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pOpening = NULL;
    CB_FUNC          callback  = Sms_Del_Scrn_Timeout;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pOpening = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pOpening, 0, sizeof(UI_Status_Desc_t));

    g_MsgGlobalCtrl.CurOpenBox = DEL_SCREENED_MESSAGES_ONEBYONE;

    pOpening->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pOpening->ContLabel.TxtId      = PHONE_TEXT_ID_OPENING;
    pOpening->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pOpening->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pOpening->ContImg.Img      = IMG_PROGRESS_BAR;
    pOpening->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pOpening->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_OPENING, &FuncList, (void *)pOpening);

    if (NULL != g_MsgGlobalCtrl.pScrnMsgContentInfo)
    {    // scrn has been read
        // 2s timer start
        Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_OPENING);
    }
    else
    {
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_RECEIVED);
    }
} /* Sms_Delete_Scrn_Options_Onebyone */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Scrn_Timeout(VOID* id)
{
    UINT32* Id = (UINT32 *)id;
    Sms_Del_Scrn_List(*Id);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Scrn_List(UINT32 id)
{
    // scrn messages list function

    UINT32                     i   = 0;
    UINT32                     Cnt = 0;
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pScrn      = NULL;
    UI_Button_Desc_t           *ButtonList = NULL;
    Msg_Content_Info_t         *pTemp      = NULL;

    pScrn = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pScrn, 0, sizeof(UI_Normal_List_Only_Desc_t));

    pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pScrnMsgContentInfo);

    while (NULL != pTemp)
    {
        Cnt++;
        pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pScrnMsgContentInfo, pTemp);
    }

    ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * Cnt);
    Hal_Mem_Set(ButtonList, 0, sizeof(UI_Button_Desc_t) * Cnt);

    g_MsgGlobalCtrl.pChart = pScrn;

    pScrn->TitleBar.TxtId      = PHONE_TEXT_ID_SCREENED_SMS;
    pScrn->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pScrn->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_MID;

    pScrn->List.ListButtonCnt = Cnt;
    pScrn->List.Index         = 0;
    pScrn->List.ButtonList    = ButtonList;

    for (i = 0; i < Cnt; i++)
    {
        if (i)
        {
            pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pScrnMsgContentInfo, pTemp);
        }
        else
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pScrnMsgContentInfo);
        }
        ButtonList[i].ButtonIndex = i;
        ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        ButtonList[i].BtnTxt      = pTemp->pContact;
        if (MMI_MODEM_UNREAD == pTemp->SmsType)
        {
            ButtonList[i].SymbolId1 = SYMBOL_UNREAD_SMS;
        }
        else
        {
            ButtonList[i].SymbolId1 = SYMBOL_READ_SMS;
        }
        if (MMI_MODEM_SIM_1 == pTemp->SimId)
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM1;
        }
        else
        {
            ButtonList[i].SymbolId2 = SYMBOL_SIM2;
        }
        ButtonList[i].ReleaseFun = NULL;
        ButtonList[i].Valid      = true;
    }
    pScrn->BtnBar.ButtonL.TxtId = PHONE_TEXT_ID_BACK;
    pScrn->BtnBar.ButtonL.Valid = true;

    pScrn->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;
    pScrn->BtnBar.ButtonM.Valid = true;

    pScrn->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_DONE;
    pScrn->BtnBar.ButtonR.Valid = true;

    pScrn->KeyFunc = Sms_Del_Scrn_Handle;

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_List_Only_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Screened_Msgs_On_Create;
    FuncList.OnDestroy      = Sms_List_Only_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;              // temp
    FuncList.OnRestoreState = Sms_Screened_Msgs_On_Create;  // temp

    Nav_Forward(id, ACT_ID_MESSAGES_SCREENED_MSGS, &FuncList, (void *)pScrn);
} /* Sms_Del_Scrn_List */

/**
 * entry of message APP
 * param (in) void
 * return  void
 */
UINT8 Sms_Del_Scrn_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8              Result  = 0;
    Msg_Content_Info_t *pTemp  = NULL;
    Msg_Content_Info_t *pTemp1 = NULL;
    lv_obj_t           *pBtn   = NULL;

    pBtn = lv_list_get_btn_selected(obj);

    pTemp1 = pBtn->user_data.user_data;
    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTLEFT == key_val)
        {
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pScrnMsgContentInfo);

            while (NULL != pTemp)
            {
                if (MMI_MODEM_UNSENT == pTemp->SmsType)
                {
                    pTemp->SmsType = MMI_MODEM_READ;
                }
                pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pScrnMsgContentInfo, pTemp);
            }
            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_OPT, NULL, NULL);
            Result = 1;
        }
        else if (KEY_SOFTRIGHT == key_val)
        {        // done
            Sms_Delete_Scrn_Onebyone_Done(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {        // select
            pTemp = _lv_ll_get_head(g_MsgGlobalCtrl.pInboxMsgContentInfo);

            while (NULL != pTemp)
            {
                if (pTemp1->MsgIndex == pTemp->MsgIndex)
                {
                    if (MMI_MODEM_UNSENT == pTemp->SmsType)
                    {                    // make to unmarked
                        lv_img_set_src(lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, NULL))), SYMBOL_READ_SMS);
                        pTemp->SmsType = MMI_MODEM_READ;
                    }
                    else
                    {                    // make to marked
                        lv_img_set_src(lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, lv_obj_get_child(pBtn, NULL))), SYMBOL_CHECKED);
                        pTemp->SmsType = MMI_MODEM_UNSENT;
                    }
                    break;
                }
                pTemp = _lv_ll_get_next(g_MsgGlobalCtrl.pInboxMsgContentInfo, pTemp);
            }
            Result = 1;
        }
    }

    return(Result);    // temp
} /* Sms_Del_Scrn_Handle */

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Scrn_Folder_Sts(VOID)
{
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pEmpty  = NULL;
    CB_FUNC          callback = Sms_Del_Scrn_Empty_Timeout;

    pEmpty = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pEmpty, 0, sizeof(UI_Status_Desc_t));

    pEmpty->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pEmpty->ContLabel.TxtId      = PHONE_TEXT_ID_SCR_FOLDER_EMPTY;
    pEmpty->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pEmpty->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pEmpty->ContImg.Img      = LV_SYMBOL_WARNING;
    pEmpty->ContImg.ImgAlign = LV_ALIGN_IN_TOP_RIGHT;
    pEmpty->ContImgAlign     = LV_ALIGN_IN_TOP_RIGHT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_FOLDER_STATUS, &FuncList, (void *)pEmpty);

    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETE_FOLDER_STATUS);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Del_Scrn_Empty_Timeout(VOID* id)
{
    // back to Messages_Delete_Msgs chart
    UINT32* Id = (UINT32 *)id;
    Nav_Forward(*Id, ACT_ID_MESSAGES_DELETE_MSGS, NULL, NULL);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Scrn_Onebyone_Done(lv_obj_t *pBtn)
{
    // create Messages_Delete_Mark_Confirm chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteOnebyone = NULL;

    pDeleteOnebyone = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteOnebyone, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart = pDeleteOnebyone;

    pDeleteOnebyone->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteOnebyone->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DELETE_MARKED_SMS_Q;
    pDeleteOnebyone->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteOnebyone->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteOnebyone->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteOnebyone->ButtonBar.ButtonR.Valid = true;

    pDeleteOnebyone->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteOnebyone->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteOnebyone->ButtonBar.ButtonM.Valid      = true;

    pDeleteOnebyone->KeyFunc = Sms_Delete_Scrn_Onebyone_Done_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_MARK_CONFIRM, &FuncList, (void *)pDeleteOnebyone);

    return(LV_RES_OK);
}

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Scrn_Onebyone_Done_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Scrn_Delete_Mark_Cnf_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Scrn_Delete_Mark_Cnf_OK(lv_obj_t *pBtn)
{
    // create Messages_Delete_Status chart
    // send the delete messages indexes to modem adapter(optional)
    // if delete finished,2 seconds timer start
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;
    CB_FUNC          callback    = Sms_Delete_All_Read_Done;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    Sms_Common_Delete_Sms(DEL_SCREENED_MESSAGES_ONEBYONE, (VOID **)&g_MsgGlobalCtrl.pScrnMsgContentInfo);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);
    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Scrn_Options_Allread(lv_obj_t *pBtn,lv_event_t event)
{
    // create Messages_Delete_Msgs chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteAllRead = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDeleteAllRead = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteAllRead, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart     = pDeleteAllRead;
    g_MsgGlobalCtrl.CurOpenBox = DEL_SCREENED_MESSAGES_ALLREAD;

    pDeleteAllRead->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteAllRead->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DEL_ALL_READ_SMS_FOLDER;
    pDeleteAllRead->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteAllRead->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteAllRead->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteAllRead->ButtonBar.ButtonR.Valid = true;

    pDeleteAllRead->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteAllRead->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteAllRead->ButtonBar.ButtonM.Valid      = true;

    pDeleteAllRead->KeyFunc = Sms_Delete_Scrn_Options_Allread_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_ALL_READ_CONFIRM, &FuncList, (void *)pDeleteAllRead);
} /* Sms_Delete_Scrn_Options_Allread */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Scrn_Options_Allread_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Scrn_Options_Allread_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Scrn_Options_Allread_OK(lv_obj_t *pBtn)
{
    if (NULL != g_MsgGlobalCtrl.pScrnMsgContentInfo)
    {    // scrn has been read
        Sms_Delete_Scrn_Options_Allread_OK_Sub();
    }
    else
    {
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_RECEIVED);
    }

    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Scrn_Options_Allread_OK_Sub(VOID)
{
    // create Messages_Delete_Status chart
    // inform modem adapter to delete all read messages
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;
    CB_FUNC          callback    = Sms_Delete_All_Read_Done;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);
    Sms_Common_Delete_Sms(DEL_SCREENED_MESSAGES_ALLREAD, (VOID **)&g_MsgGlobalCtrl.pScrnMsgContentInfo);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn,lv_event_t event
 * return  VOID
 */
VOID Sms_Delete_Scrn_Options_All(lv_obj_t *pBtn,lv_event_t event)
{
    // create Messages_Delete_Msgs chart
    Nav_Func_List_t          FuncList;
    UI_Normal_NoTitle_Desc_t *pDeleteAll = NULL;

    if(LV_EVENT_CLICKED != event)
    {
        return;
    }

    pDeleteAll = (UI_Normal_NoTitle_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_NoTitle_Desc_t));
    Hal_Mem_Set(pDeleteAll, 0, sizeof(UI_Normal_NoTitle_Desc_t));

    g_MsgGlobalCtrl.pChart     = pDeleteAll;
    g_MsgGlobalCtrl.CurOpenBox = DEL_SCREENED_MESSAGES_ALL;

    pDeleteAll->ContenCont.ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteAll->ContenCont.ContLabel.TxtId      = PHONE_TEXT_ID_DEL_ALL_SMS_FOLDER;
    pDeleteAll->ContenCont.ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteAll->ContenCont.ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteAll->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
    pDeleteAll->ButtonBar.ButtonR.Valid = true;

    pDeleteAll->ButtonBar.ButtonM.TxtId      = PHONE_TEXT_ID_OK;
    pDeleteAll->ButtonBar.ButtonM.ReleaseFun = NULL;
    pDeleteAll->ButtonBar.ButtonM.Valid      = true;

    pDeleteAll->KeyFunc = Sms_Delete_Scrn_Options_All_Handle;     // common

    FuncList.OnShow         = (Void_P_Func_t)UI_Normal_NoTitle_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETE_ALL_CONFIRM, &FuncList, (void *)pDeleteAll);
} /* Sms_Delete_Scrn_Options_All */

/**
 * entry of message APP
 * param (in) lv_obj_t * obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val
 * return  UINT8
 */
UINT8 Sms_Delete_Scrn_Options_All_Handle(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UINT8 Result = 0;

    // handle the return key
    if (KEY_RELEASED == key_sta)
    {
        if (KEY_SOFTRIGHT == key_val)
        {
            Nav_Back(ACT_ID_ANY);
            Result = 1;
        }
        else if (KEY_OK == key_val)
        {
            Sms_Delete_Scrn_Options_All_OK(NULL);
            Result = 1;
        }
        else if (KEY_END == key_val)
        {
            Nav_Home(ACT_ID_ANY);
            Result = 1;
        }
    }

    return(Result);   // temp
}

/**
 * sub-module entry
 * param (in) lv_obj_t *pBtn
 * return  lv_res_t
 */
lv_res_t Sms_Delete_Scrn_Options_All_OK(lv_obj_t *pBtn)
{
    if (NULL != g_MsgGlobalCtrl.pScrnMsgContentInfo)
    {    // scrn has been read
        Sms_Delete_Scrn_Options_All_OK_Sub();
    }
    else
    {
        MMI_Modem_Read_Sms_Info_Req(MMI_MODEM_SMS_RECEIVED);
    }

    return(LV_RES_OK);
}

/**
 * sub-module entry
 * param (in) VOID
 * return  VOID
 */
VOID Sms_Delete_Scrn_Options_All_OK_Sub(VOID)
{
    // create Messages_Delete_Status chart
    // inform modem adapter to delete all messages
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDeleteSts = NULL;
    CB_FUNC          callback    = Sms_Delete_All_Read_Done;

    pDeleteSts = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    Hal_Mem_Set(pDeleteSts, 0, sizeof(UI_Status_Desc_t));

    pDeleteSts->ContLabel.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    pDeleteSts->ContLabel.TxtId      = PHONE_TEXT_ID_DELETING_MESSAGE;
    pDeleteSts->ContLabel.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    pDeleteSts->ContLabelAlign       = LV_ALIGN_IN_TOP_LEFT;

    pDeleteSts->ContImg.Img = IMG_PROGRESS_BAR;

    pDeleteSts->ContImg.ImgAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    pDeleteSts->ContImgAlign     = LV_ALIGN_IN_BOTTOM_LEFT;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = Sms_Common_Create;
    FuncList.OnDestroy      = Sms_Common_Destory; // temp,delete all global
    FuncList.OnSaveState    = Sms_Common_Save;    // temp
    FuncList.OnRestoreState = Sms_Common_Restore; // temp

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_DELETED_STATUS, &FuncList, (void *)pDeleteSts);

    Sms_Common_Delete_Sms(DEL_SCREENED_MESSAGES_ALL, (VOID **)&g_MsgGlobalCtrl.pScrnMsgContentInfo);
    // 2s timer start
    Sms_Timer_Create_And_Start(callback, ACT_ID_MESSAGES_DELETED_STATUS);
}
